package org.example.what_mall.dto;

import lombok.Data;
import org.example.what_mall.entity.Goods;
import org.example.what_mall.entity.Spec;

@Data
public class GoodsOrderDTO {
    private Integer id;
    private String name;
    private String img;
    private String spec;
    private Integer unitPrice;

    public static GoodsOrderDTO of(Goods goods, Spec spec) {
        GoodsOrderDTO dto = new GoodsOrderDTO();
        dto.setId(goods.getId());
        dto.setName(goods.getName());
        dto.setImg(goods.getImg());
        dto.setSpec(spec.getSpecName());
        dto.setUnitPrice(spec.getUnitPrice());
        return dto;
    }
}
